<?php
namespace Home\Controller;

use Think\Controller;

class GetCommandController extends Controller
{

    public function getAll($tableName)
    {
        $table = M($tableName, '', 'DB_CONFIG1');
        $result = $table->select();
        echo "<table border=" . "1" . ">";
        echo "<tr>";
        foreach ($result[0] as $x => $x_value) {
            echo "<th>" . $x . "</th>";
        }
        echo "</tr>";
        for ($i = 0; $i < count($result); $i ++) {
            echo "<tr><td>";
            echo implode("</td><td>", $result[$i]);
            echo "</td></tr>";
        }
        echo "</table>";
    }
    
    public function index()
    {
//         $this->getAll("tcommand");
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>GetTest</title>
</head>
<body>
	<table>
		<tr>
			<th>
				<form action="getAll" method="get">
					<input type="text" hidden="true" value="tcommand" name="tableName">
					<input type="submit" value="获取tcommand表">
				</form>
			</th>
			<th>
				<form action="getAll" method="get">
					<input type="text" hidden="true" value="treseller" name="tableName">
					<input type="submit" value="获取treseller表">
				</form>
			</th>
			<th>
				<form action="getAll" method="get">
					<input type="text" hidden="true" value="troom" name="tableName">
					<input type="submit" value="获取troom表">
				</form>
			</th>
			<th>
				<form action="getAll" method="get">
					<input type="text" hidden="true" value="tstylecategory" name="tableName">
					<input type="submit" value="获取tstylecategory表">
				</form>
			</th>
		</tr>
	</table>
</body>
</html>